class Calculator {
  // 定义 calculate 方法，接收两个整数和一个操作符作为参数
  def calculate(x: Int, y: Int, operator: Char): Any = {
    // 使用 match 语句根据操作符执行相应的计算
    operator match {
      case '+' => x + y
      case '-' => x - y
      case '*' => x * y
      case '/' => if (y != 0) x / y else "Division by zero"
      case _ => "Invalid operator"
   }
  }
}
/*
//测试
object Main {
  def main(args: Array[String]): Unit = {
    val calculator = new Calculator()
    println(calculator.calculate(10, 5, '+')) 
    println(calculator.calculate(10, 5, '-'))
    println(calculator.calculate(10, 5, '*'))
    println(calculator.calculate(10, 5, '/'))
    println(calculator.calculate(10, 5, '%')) // 输出："Invalid operator"
  }
}
*/
